Voorbeeld van de functie Loc

Dit voorbeeld maakt gebruik van de functie Loc om de huidige lees-/schrijfpositie in een geopend bestand als resultaat te geven. Dit voorbeeld gaat ervan uit dat TESTBSTD een tekstbestand is met enkele regels proefgegevens.

Dim MyLocation, MyLine
Open "TESTBSTD" For Binary As #1    ' Open file just created.
Do While MyLocation < LOF(1)    ' Loop until end of file.
    MyLine = MyLine & Input(1, #1)    ' Read character into variable.
    MyLocation = Loc(1)    ' Get current position within file.
' Print to the Immediate window.
    Debug.Print MyLine; Tab; MyLocation
Loop
Close #1    ' Close file.